package com.android.lovely.data

import android.os.Parcelable
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import kotlinx.parcelize.Parcelize

/**
 * 创建图片任务的数据类
 * @author why
 * @date 2025/4/10 23:32
 */
@JsonClass(generateAdapter = true)
@Parcelize
data class ImageGenerationTask(
    @Json(name = "id") val id: Int = 0,
    @Json(name = "status") val status: Int = 0,
    @Json(name = "img") val imageUrl: String = "",
    @Json(name = "type") val type: Int = 0,
    @Json(name = "num") val count: Int = 0,
    @Json(name = "style") val style: Int = 0,
    @Json(name = "detail") val detail: ImageGenerationDetail = ImageGenerationDetail(),
) : Parcelable

@Parcelize
@JsonClass(generateAdapter = true)
data class ImageGenerationDetail(
    @Json(name = "model") val modelName: String = "",
    @Json(name = "style") val styleAttributes: Map<String, String> = emptyMap(),
    @Json(name = "gender") val gender: Int = 2,
    @Json(name = "age") val age: String = "",
    @Json(name = "height") val height: String = "",
    @Json(name = "workflow_type") val workflowType: String = "",
    @Json(name = "is_nsfw") val isNsfw: String = "",
    @Json(name = "text_input") val prompt: String = "",
    @Json(name = "param") val parameters: ImageGenerationParameters = ImageGenerationParameters(),
) : Parcelable

@JsonClass(generateAdapter = true)
data class GeneratedImageResult(
    @Json(name = "aws_result") val imageUrls: List<String> = listOf()
)

@JsonClass(generateAdapter = true)
data class ImageGenerationRequest(
    @Json(name = "age") val age: String = "",
    @Json(name = "batch_size") val batchSize: String = "",
    @Json(name = "client_id") val clientId: String = "",
    @Json(name = "gender") val gender: String = "",
    @Json(name = "height") val height: String = "",
    @Json(name = "image_name") val imageName: String = "",
    @Json(name = "image_subfolder") val imageSubfolder: String = "",
    @Json(name = "is_nsfw") val isNsfw: String = "",
    @Json(name = "model") val model: String = "",
    @Json(name = "param") val parameters: ImageParameters = ImageParameters(),
    @Json(name = "style") val style: ImageStyle = ImageStyle(),
    @Json(name = "text_input") val prompt: String = "",
    @Json(name = "weight") val weight: Int = 0,
    @Json(name = "workflow_type") val workflowType: String = ""
)

@JsonClass(generateAdapter = true)
data class ImageParameters(
    @Json(name = "type_action") val actions: List<String> = listOf(),
    @Json(name = "type_angle") val angles: List<String> = listOf(),
    @Json(name = "type_breast") val breastTypes: List<String> = listOf(),
    @Json(name = "type_clothes") val clothingTypes: List<String> = listOf(),
    @Json(name = "type_descent") val descentTypes: List<String> = listOf(),
    @Json(name = "type_distance") val distances: List<String> = listOf(),
    @Json(name = "type_face") val faceTypes: List<String> = listOf(),
    @Json(name = "type_figure") val bodyTypes: List<String> = listOf(),
    @Json(name = "type_hair_color") val hairColors: List<String> = listOf(),
    @Json(name = "type_hair_style") val hairStyles: List<String> = listOf(),
    @Json(name = "type_scenes") val scenes: List<String> = listOf(),
    @Json(name = "type_sexual_positions") val positions: List<String> = listOf(),
    @Json(name = "type_skin") val skinTypes: List<String> = listOf(),
    @Json(name = "type_specie") val species: List<String> = listOf()
)

@JsonClass(generateAdapter = true)
data class ImageStyle(
    @Json(name = "None") val none: String = ""
)

@Parcelize
@JsonClass(generateAdapter = true)
data class ImageGenerationParameters(
    @Json(name = "type_hair_style") val hairStyles: List<String> = emptyList(),
    @Json(name = "type_hair_color") val hairColors: List<String> = emptyList(),
    @Json(name = "type_face") val faceTypes: List<String> = emptyList(),
    @Json(name = "type_specie") val species: List<String> = emptyList(),
    @Json(name = "type_figure") val bodyTypes: List<String> = emptyList(),
    @Json(name = "type_breast") val breastTypes: List<String> = emptyList(),
    @Json(name = "type_skin") val skinTypes: List<String> = emptyList(),
    @Json(name = "type_descent") val descentTypes: List<String> = emptyList(),
    @Json(name = "type_action") val actions: List<String> = emptyList(),
    @Json(name = "type_clothes") val clothingTypes: List<String> = emptyList(),
    @Json(name = "type_scenes") val scenes: List<String> = emptyList(),
    @Json(name = "type_angle") val angles: List<String> = emptyList(),
    @Json(name = "type_distance") val distances: List<String> = emptyList(),
    @Json(name = "type_sexual_positions") val positions: List<String> = emptyList()
) : Parcelable {

    fun toMap(): Map<String, List<String>> {
        return mapOf(
            "type_hair_style" to hairStyles,
            "type_hair_color" to hairColors,
            "type_face" to faceTypes,
            "type_specie" to species,
            "type_figure" to bodyTypes,
            "type_breast" to breastTypes,
            "type_skin" to skinTypes,
            "type_descent" to descentTypes,
            "type_action" to actions,
            "type_clothes" to clothingTypes,
            "type_scenes" to scenes,
            "type_angle" to angles,
            "type_distance" to distances,
            "type_sexual_positions" to positions
        )
    }
}